package com.company.demo.config;

import com.company.demo.handlers.SomeInterceptorHandler;
import com.company.demo.interceptor.SomeInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

//拦截器
@Configuration//表示该文件充当配置文件
public class MyWebMvcConfiguration extends WebMvcConfigurationSupport {

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        SomeInterceptor si = new SomeInterceptor();
        registry.addInterceptor(si)//自定义拦截器的对象
                .addPathPatterns("/first/**")//拦截first开头的路径
                .excludePathPatterns("/second/**");//不拦截second开头的路径
    }
}
